/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package obj;

import EntityBeans.Product;
import java.text.NumberFormat;

/**
 *
 * @author Pierre
 */
public class ItemCart {

   
    private int id;
    private int qte;
    private Product prod;
    
    public ItemCart(Product Prod, int QTE)
    {
        prod = Prod;
        qte = QTE;
     /*   for (ItemCart item: listItems)
        {
            int iditem = (int)item.getId();
           Product prod = productFacade.ProductByID(iditem);
           Cart.add(new DisplayItem(prod, item.getQte()));
        }*/
        
    }
    
    
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getQte() {
        return qte;
    }

    public void setQte(int qte) {
        this.qte = qte;
    }

    /**
     * @return the prod
     */
    public Product getProd() {
        return prod;
    }

    /**
     * @param prod the prod to set
     */
    public void setProd(Product prod) {
        this.prod = prod;
    }
    
    public String getType() {
        String type = "";
        if (prod.getType() == 1)
        {
            type = "Music";
        }
        else
        {
            type = "Film";
        }
       return type;
    }
    
    public String getCout() {
        
        double vartmp = 0.00;
        vartmp = prod.getPrice().doubleValue() * qte;
        
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2); // la tu auras au plus 2 chiffres apres la virgule
        nf.setMinimumFractionDigits(2);  // maintenant tout tes nombres auront 2 chiffres après la virgule

        
        return  nf.format(vartmp) +" €";

    }
    

    
}
